<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.2.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css" integrity="sha256-2H3fkXt6FEmrReK448mDVGKb3WW2ZZw35gI7vqHOE4Y=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"singingxy.github.io","root":"/","images":"/images","scheme":"Gemini","version":"8.6.1","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>
<meta name="description" content="VS Code 升级后有关 ESlint 自动修复的配置有变更。在settings.json文件中发现了如下报错这个设置项已经弃用了，请使用 editor.codeActionsOnSave 和 source.fixAll.eslint。">
<meta property="og:type" content="article">
<meta property="og:title" content="VSCode升级，ESLint自动修复的设置更新">
<meta property="og:url" content="https://singingxy.github.io/2020/vscode-eslint/index.html">
<meta property="og:site_name" content="sing&#39;s blog">
<meta property="og:description" content="VS Code 升级后有关 ESlint 自动修复的配置有变更。在settings.json文件中发现了如下报错这个设置项已经弃用了，请使用 editor.codeActionsOnSave 和 source.fixAll.eslint。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://singingxy.github.io/2020/vscode-eslint/1.png">
<meta property="og:image" content="https://singingxy.github.io/2020/vscode-eslint/2.png">
<meta property="og:image" content="https://singingxy.github.io/2020/vscode-eslint/3.png">
<meta property="article:published_time" content="2020-01-14T05:20:27.000Z">
<meta property="article:modified_time" content="2020-01-14T05:20:27.000Z">
<meta property="article:author" content="Sing">
<meta property="article:tag" content="VS Code">
<meta property="article:tag" content="Eslint">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://singingxy.github.io/2020/vscode-eslint/1.png">


<link rel="canonical" href="https://singingxy.github.io/2020/vscode-eslint/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://singingxy.github.io/2020/vscode-eslint/","path":"/2020/vscode-eslint/","title":"VSCode升级，ESLint自动修复的设置更新"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>VSCode升级，ESLint自动修复的设置更新 | sing's blog</title>
  




  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">sing's blog</h1>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">C'est La Vie Mon Ami.</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>







</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-overview-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-overview">
            <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">Sing</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives">
          <span class="site-state-item-count">18</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
        <span class="site-state-item-count">2</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
        <span class="site-state-item-count">25</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



          </div>
        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://singingxy.github.io/2020/vscode-eslint/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="Sing">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="sing's blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          VSCode升级，ESLint自动修复的设置更新
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2020-01-14 13:20:27" itemprop="dateCreated datePublished" datetime="2020-01-14T13:20:27+08:00">2020-01-14</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B0%8F%E9%97%AE%E9%A2%98/" itemprop="url" rel="index"><span itemprop="name">小问题</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <p>VS Code 升级后有关 ESlint 自动修复的配置有变更。<br>在<code>settings.json</code>文件中发现了如下报错<br><img src="/2020/vscode-eslint/1.png"><br>这个设置项已经弃用了，请使用 <code>editor.codeActionsOnSave</code> 和 <code>source.fixAll.eslint</code>。</p>
<span id="more"></span>

<p>于是改成了下面这样：</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&quot;editor.codeActionsOnSave&quot;: &#123; //在保存时运行以下</span><br><span class="line">    &quot;source.fixAll.eslint&quot;: true // 开启eslint格式化工具</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<p>下面还有一个报错：<br><img src="/2020/vscode-eslint/2.png"></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Auto Fix is enabled by default. Use the single string form.</span><br></pre></td></tr></table></figure>

<p>默认情况下<code>Auto Fix</code>已经启用了。</p>
<p>官方介绍是这么写的：</p>
<blockquote>
<p><code>eslint.probe</code> = an array for language identifiers for which the ESLint extension should be activated and should try to validate the file. If validation fails for probed languages the extension says silent. Defaults to <code>[&quot;javascript&quot;, &quot;javascriptreact&quot;, &quot;typescript&quot;, &quot;typescriptreact&quot;, &quot;html&quot;, &quot;vue&quot;]</code>.</p>
</blockquote>
<blockquote>
<p><code>eslint.validate</code> - an array of language identifiers specifying the files for which validation is to be enforced. This is an old legacy setting and should in normal cases not be necessary anymore. Defaults to <code>[&quot;javascript&quot;, &quot;javascriptreact&quot;]</code>.</p>
</blockquote>
<p><code>eslint.validate</code>这个旧的属性已经不再需要了，而新属性<code>eslint.probe</code>默认值已经加入了<code>vue</code>和<code>html</code>文件的验证。</p>
<p>进到扩展设置里可看到这一项:<br><img src="/2020/vscode-eslint/3.png"></p>
<p>所以修改方法就是把<code>eslint.validate</code>这一项删除就好了。</p>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/VS-Code/" rel="tag"># VS Code</a>
              <a href="/tags/Eslint/" rel="tag"># Eslint</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2020/flex/" rel="prev" title="flex布局">
                  <i class="fa fa-chevron-left"></i> flex布局
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2020/update-hexo/" rel="next" title="升级了hexo，顺便换成了next主题">
                  升级了hexo，顺便换成了next主题 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Sing</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>

  




  





</body>
</html>
